package com.eagle.coders.security.transaction.beans;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

//@Entity
//@Table(name = "SY01USR")
//@NamedQuery(name = "SecurityUser.findUserWithLimits", query = "select distinct "
//                + "u from SecurityUser u " + "join fetch u.userLimits "
//                + "where u.userGroup = :userGroup and u.userLevel = :userLevel ")
public class SecurityUser implements Serializable {
	//extends BaseDomainObject{
	private static final long serialVersionUID = 1L;

	public SecurityUser() {
    }

    public SecurityUser(String userId) {
        this.userId = userId;
    }

    private String userId;

    private String password;

    private String branchCode;

    private String userGroup;

    private Short userLevel;

    private Date createDate;

    private String status;

    private String lastIpAddress;

    private Date expiredDate;

    private Date passwordExpiredDate;

    private Date lastLogon;

    private Date lastPasswordChange;

    private String staffId;

    private String name;

    private String remarks;

    private String locale;

    private String themeCode;

    private String emailAddress;

    private String mobileNumber;
    
    private List<UserLimit> userLimits;
    
//    @ValidateMandatory
//    @ValidateString(maxLength = 15)
    public void setUserId(String userId) {
//        firePropertyChange("userId", this.userId, userId);
        this.userId = userId;
    }

    @Id
    @Column(name = "USR_ID")
    public String getUserId() {
        return userId;
    }

//    @ValidateMandatory
    public void setPassword(String password) {
//        firePropertyChange("password", this.password, password);
        this.password = password;
    }

    @Column(name = "PSWD")
    public String getPassword() {
        return password;
    }
//
//    @ValidateString(maxLength = 10)
//    @ValidateMandatory
    public void setBranchCode(String branchCode) {
//        firePropertyChange("branchCode", this.branchCode, branchCode);
        this.branchCode = branchCode;
    }

    @Column(name = "BRN_CD")
    public String getBranchCode() {
        return branchCode;
    }

//    @ValidateString(maxLength = 10)
//    @ValidateMandatory
    public void setUserGroup(String userGroup) {
//        firePropertyChange("userGroup", this.userGroup, userGroup);
        this.userGroup = userGroup;
    }

    @Column(name = "USR_GRP")
    public String getUserGroup() {
        return userGroup;
    }

//    @ValidateMandatory
//    @ValidateNumeric(minValue = 0, maxValue = 99)
    public void setUserLevel(Short userLevel) {
//        firePropertyChange("userLevel", this.userLevel, userLevel);
        this.userLevel = userLevel;
    }

    @Column(name = "USR_LVL")
    public Short getUserLevel() {
        return userLevel;
    }

//    @ValidateMandatory
    public void setCreateDate(Date createDate) {
//        firePropertyChange("createDate", this.createDate, createDate);
        this.createDate = createDate;
    }

    @Column(name = "CRT_DT_TS")
    public Date getCreateDate() {
        return createDate;
    }

//    @ValidateMandatory
//    @ValidateString(maxLength = 1)
    public void setStatus(String status) {
//        firePropertyChange("status", this.status, status);
        this.status = status;
    }

    @Column(name = "STS")
    public String getStatus() {
        return status;
    }

//    @ValidateString(maxLength = 15)
    public void setLastIpAddress(String lastIpAddress) {
//        firePropertyChange("lastIpAddress", this.lastIpAddress, lastIpAddress);
        this.lastIpAddress = lastIpAddress;
    }

    @Column(name = "LAST_IP_ADDR")
    public String getLastIpAddress() {
        return lastIpAddress;
    }

    public void setExpiredDate(Date expiredDate) {
//        firePropertyChange("expiredDate", this.expiredDate, expiredDate);
        this.expiredDate = expiredDate;
    }

    @Column(name = "EXP_DT_TS")
    public Date getExpiredDate() {
        return expiredDate;
    }

    public void setPasswordExpiredDate(Date passwordExpiredDate) {
//        firePropertyChange("passwordExpiredDate", this.passwordExpiredDate, passwordExpiredDate);
        this.passwordExpiredDate = passwordExpiredDate;
    }

    @Column(name = "PSWD_EXP_DT_TS")
    public Date getPasswordExpiredDate() {
        return passwordExpiredDate;
    }

    public void setLastLogon(Date lastLogon) {
//        firePropertyChange("lastLogon", this.lastLogon, lastLogon);
        this.lastLogon = lastLogon;
    }

    @Column(name = "LAST_LOGON_DT_TS")
    public Date getLastLogon() {
        return lastLogon;
    }

    public void setLastPasswordChange(Date lastPasswordChange) {
//        firePropertyChange("lastPasswordChange", this.lastPasswordChange, lastPasswordChange);
        this.lastPasswordChange = lastPasswordChange;
    }

    @Column(name = "LAST_PSWD_CHG_DT_TS")
    public Date getLastPasswordChange() {
        return lastPasswordChange;
    }

//    @ValidateString(maxLength = 15)
    public void setStaffId(String staffId) {
//        firePropertyChange("staffId", this.staffId, staffId);
        this.staffId = staffId;
    }

    @Column(name = "STAFF_ID")
    public String getStaffId() {
        return staffId;
    }

//    @ValidateString(maxLength = 60)
    public void setName(String name) {
//        firePropertyChange("name", this.name, name);
        this.name = name;
    }

    @Column(name = "NAME")
    public String getName() {
        return name;
    }

//    @ValidateString(maxLength = 255)
    public void setRemarks(String remarks) {
//        firePropertyChange("remarks", this.remarks, remarks);
        this.remarks = remarks;
    }

    @Column(name = "REMARKS")
    public String getRemarks() {
        return remarks;
    }

//    @ValidateString(maxLength = 10)
    public void setLocale(String locale) {
        this.locale = locale;
    }

    @Column(name = "LOCALE")
    public String getLocale() {
        return locale;
    }

//    @ValidateString(maxLength = 30)
    public void setThemeCode(String themeCode) {
        this.themeCode = themeCode;
    }

    @Column(name = "THEME")
    public String getThemeCode() {
        return themeCode;
    }

//    @ValidateEmail
    public void setEmailAddress(String emailAddress) {
//        firePropertyChange("emailAddress", this.emailAddress, emailAddress);
        this.emailAddress = emailAddress;
    }

    @Column(name = "EMAIL_ADDR")
    public String getEmailAddress() {
        return emailAddress;
    }

//    @ValidateString(maxLength = 15)
    public void setMobileNumber(String mobileNumber) {
        this.mobileNumber = mobileNumber;
    }

    @Column(name = "MOBILE_NO")
    public String getMobileNumber() {
        return mobileNumber;
    }

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "securityUser", targetEntity = UserLimit.class)
    public List<UserLimit> getUserLimits() {
        return userLimits;
    }

    public void setUserLimits(List<UserLimit> userLimits) {
        this.userLimits = userLimits;
    }
    
}
